//
//  ViewController.swift
//  UIKitBasic
//
//  Created by itshizhan on 2020/9/30.
//  Copyright © 2020 itshizhan. All rights reserved.
//

import UIKit

class ViewController: UIViewController {
	
	var window:UIWindow!


	override func viewDidLoad() {
		super.viewDidLoad()
		// Do any additional setup after loading the view.
		print("hello basic")
		let lable = UILabel(frame:  CGRect(x: 100, y: 100, width:  100, height: 100))
		lable.text = "hello"
		lable.font = UIFont.systemFont(ofSize:20)
		view.addSubview(lable)
		let point = CGPoint(x: 100, y: 100)
		print(point.x )
		let size = CGSize(width: 100, height: 100)
		print(size.width)
		let zeroSize = CGSize.zero
		print(zeroSize.width)
		
		//CGRect(origin: T##CGPoint, size: <#T##CGSize#>)
		let deviceW = UIScreen.main.bounds.size.width
		let deviceH = UIScreen.main.bounds.size.height
		
		print("W= \(deviceW) , H=\(deviceH)")
		
		// 16进制颜色 -> UIColor , rgba(40, 196, 124, 1)
		// UIColor(red: <#T##CGFloat#>, green: <#T##CGFloat#>, blue: <#T##CGFloat#>, alpha: <#T##CGFloat#>)
		let color = UIColor.rgba(red: 40, green: 196, blue: 124,alpha: 1.0)
		lable.textColor = color
		
		getAllSystemFonts()
		
		
		let label1 = UILabel(frame: CGRect(x: 10, y: 200, width: 400, height: 50));
		label1.text = "preferredFont";
		label1.font = UIFont.preferredFont(forTextStyle: .title1);
		view.addSubview(label1);


	}
	

	
	func getAllSystemFonts() {
			UIFont.familyNames.map {
						UIFont.fontNames(forFamilyName: $0);
					}.forEach { (fonts:[String]) in
							fonts.forEach({
									print($0);
							})
			};
					
	}
}

extension UIColor {
    // Method returns a custom color
	static func rgba(red: CGFloat, green: CGFloat, blue: CGFloat,alpha:CGFloat) -> UIColor {
		return .init(red: blue / 255, green: green / 255, blue: blue / 255, alpha: alpha)
	}
}

